package com.gpnu.crm.domain;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.Data;

@Data
public class CustomerTransfer {
	private long id;
	private Customer customer;
	private Date operateTime;
	private Employee oldSeller;
	private Employee newSeller;
	private String reason;
	private Employee operator;
	public String getJson() throws Exception {
		ObjectMapper mapper = new ObjectMapper();
		Map<String, Object> map = new HashMap<>();
		map.put("id", id);
		map.put("customerId", customer.getId());
		map.put("customerName", customer.getName());
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		map.put("operateTime", format.format(operateTime));
		map.put("oldSellerId", oldSeller.getId());
		map.put("oldSellerName", oldSeller.getName());
		map.put("newSellerId", newSeller.getId());
		map.put("newSellerName", newSeller.getName());
		map.put("reason", reason);
		map.put("operatorId",operator.getId());
		map.put("operatorName", operator.getName());
		return mapper.writeValueAsString(map);
	}


}